﻿
using System.Runtime.CompilerServices;

namespace Graph.Algorithm.Core
{
    public static class GraphService
    {
        public static GraphEdge At(this IEnumerable<GraphEdge> edges, int stIndex, int edIndex)
        {
            var okEdges = edges
                .Where(e => e.stVertexId == stIndex)
                .Where(e => e.edVertexId == edIndex)
                .ToList();
            if (okEdges.Count == 0)
            { return new GraphEdge(); }
            return okEdges.First();
        }

        public static IEnumerable<GraphEdge> AtSt(this IEnumerable<GraphEdge> edges, int stIndex)
        {
            var okEdges = edges
                .Where(e => e.stVertexId == stIndex)
                .ToList();
            if (okEdges.Count == 0)
            { return new List<GraphEdge>(); }
            return okEdges;
        }

        public static IEnumerable<GraphEdge> AtEd(this IEnumerable<GraphEdge> edges, int edIndex)
        {
            var okEdges = edges
                .Where(e => e.stVertexId == edIndex)
                .ToList();
            if (okEdges.Count == 0)
            { return new List<GraphEdge>(); }
            return okEdges;
        }



    }
}
